/*
 * VHClubSummaryTab.java
 * Created on 21 sept. 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package com.hockeo.vhweb.client.ui.tabs;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.hockeo.vhweb.client.VHMain;
import com.hockeo.vhweb.client.mvc.VHController;
import com.hockeo.vhweb.client.ui.base.VHTabItem;
import com.hockeo.vhweb.client.ui.widget.VHClubSummaryGrid;
import com.hockeo.vhweb.client.utils.VHJsData;

/**
 * Simple tab containing a table with the most important information about a club.
 *
 * @version $Id$
 * @author jjanke
 */
public class VHClubSummaryTab extends VHTabItem
{
  private VHJsData          d_club;
  private VHClubSummaryGrid d_clubSummaryGrid;

  public VHClubSummaryTab( VHController controller, VHJsData club )
  {
    super( controller, VHMain.getConstants().clubSummary() );

    d_club = club;

    setIcon( VHMain.ICON_CLUB );
  }

  public void setClub( VHJsData club )
  {
    d_club = club;
    if ( d_clubSummaryGrid != null )
      d_clubSummaryGrid.setClub( club );
  }

  @Override
  public void buildContent()
  {
    BorderLayoutData data;

    if ( isContentReady() )
      return;

    setLayoutOnChange( true );

    d_clubSummaryGrid = new VHClubSummaryGrid( d_club );
    data = new BorderLayoutData( LayoutRegion.CENTER );
    data.setMargins( new Margins( 4, 4, 4, 4 ) );
    add( d_clubSummaryGrid, data );

    super.buildContent();
  }
}
